/**
  * Sorts the items in a listbox by their value
  * @param list The SELECT element to sort
  */
function sortSelect(list) {
    if (null !== list && list.tagName.toLowerCase() == "select") {
        var len = list.options.length;
        var tmpItems = new Array(len);
        var i;
        var opt;
        for (i = 0; i < len; i++) {
            opt = new Option(list.options[i].text, list.options[i].value);
            opt.selected = list.options[i].selected;
            tmpItems[i] = opt;
        }
        tmpItems.sort(function(obj, otherObj) {
            return obj.text != otherObj.text ? obj.text < otherObj.text ? -1 : 1 : 0;
        });
        for (i = 0; i < len; i++) {
            opt = new Option(tmpItems[i].text, tmpItems[i].value);
            opt.selected = tmpItems[i].selected;
            list.options[i] = opt;
        }
    }
}